<html>
<head>
<style type="text/css">
table {
	font-size: 12px;
}
.param {
	size: 200px;
	overflow: hidden;
	display: none;
}
.detail {
	display: none;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
<script type="text/javascript">
function showHide(id) {
	\$(id).toggle();
}
</script>
</head>
<body>

<h3>V1 : ${report.firstName}</h3>
<h3>V2 : ${report.secondName}</h3>

<% if (!report.contextResultReports.empty) { %>
<table>
<thead>
<tr>
<th>Context</th>
<th>Store</th>
<th>Method</th>
<th>Exec time</th>
</tr>
</thead>
<%
id = 0
report.contextResultReports.each {contextResultReport ->
	contextResultReport.storeResultReports.each {storeResultReport ->
		storeResultReport.methodResultReports.each {methodResultReport ->
			methodCompareReport = methodResultReport.compareReport
			methodCompareReport.paramCompareReports.each {paramCompareReport ->
				if (paramCompareReport.comparable) {
					firstReports = paramCompareReport.firstReports
					firstTotalExecTime = firstReports.totalExecTime
					firstCount = firstReports.count
					firstAvgTime = (double)firstTotalExecTime/firstCount
					
					secondReports = paramCompareReport.secondReports
					secondTotalExecTime = secondReports.totalExecTime
					secondCount = secondReports.count
					secondAvgTime = (double)secondTotalExecTime/secondCount
					
					overhead = Math.round((secondAvgTime - firstAvgTime) / firstAvgTime*100)
					
					id++
					
%>
<td>$contextResultReport.name</td>
<td>$storeResultReport.store</td>
<td>$methodResultReport.method</td>
<td ${overhead > 0 ? 'style="background:red"' : (overhead <= 0 ? 'style="background:green"' :'')}
	onclick="showHide('#row-$id')">
${overhead}%
<div id="row-$id" class="detail">
<h4>$paramCompareReport.param</h4>

<h5>V1</h5>
<table>
<thead>
<tr>
<th>Param</th>
<th>Exec time</th>
</tr>
</thead>
<% 
firstReports.reports.each {paramResultReport ->
	paramResultReport.items.each {paramResultItem ->
%>
<tr>
<td>$paramResultReport.param</td><td>$paramResultItem.execTime</td>
</tr>
<%
	}
}
%>
</table>
<h5>V2</h5>
<table>
<thead>
<tr>
<th>Param</th>
<th>Exec time</th>
</tr>
</thead>
<% 
secondReports.reports.each {paramResultReport ->
	paramResultReport.items.each {paramResultItem ->
%>
<tr>
<td>$paramResultReport.param</td><td>$paramResultItem.execTime</td>
</tr>
<%
	}
}
%>
</table>
</div>
</td>
</tr>
<%				
				}
			}
		}
	}
}
%>
</table>
<% } %>
</body>
</html>